<?PHP

	class tpl_calendar {
	
		public static function calendar_page_inner(){
		
			return	tpl_globals::header() .
				tpl_globals::global_styles_shared() .
				tpl_globals::inner_global_styles() .
				tpl_globals::form_styles2() .
				<<<EOV
<div style='float: left; width: 49%;'>
EOV
.
				tpl_calendar::calendar_display() .
<<<EOV
</div>
	<div style='width: 49%; float: right;' class='form_container'>
		<div class='row title'>
			{$GLOBALS['LANG']->lang_intro->scheduled_events}
		</div>
		<div class='row even' id='curevent'><i>{$GLOBALS['LANG']->lang_intro->click_day}</i></div>
	</div>
<div style='clear: both'>&nbsp;</div>
EOV
.
				tpl_globals::welcome_footer() .
				tpl_globals::footer();
		
		}
		
		public static function calendar_page_welcome(){
		
			return	tpl_globals::header() .
				tpl_globals::global_styles_shared() .
				tpl_globals::outer_global_styles() .
				tpl_globals::welcome_header('calendar') .
				tpl_globals::form_styles2() .
				<<<EOV
<div style='float: left; width: 49%;'>
EOV
.
				tpl_calendar::calendar_display() .
<<<EOV
</div>
	<div style='width: 49%; float: right;' class='form_container'>
		<div class='row title'>
			{$GLOBALS['LANG']->lang_intro->scheduled_events}
		</div>
		<div class='row even' id='curevent'><i>{$GLOBALS['LANG']->lang_intro->click_day}</i></div>
	</div>
<div style='clear: both'>&nbsp;</div>
EOV
.
				tpl_globals::welcome_footer() .
				tpl_globals::footer();
		
		}
		
		public static function calendar_display(){
			
			$rowdata = '';
			for($row = 0; $row < 6; $row++){
				
				$rowdata .= "<tr>\n";
				
				for($col = 1; $col < 8; $col++){
					
					if(empty($GLOBALS['OUTPUT']->caldata[$row*7+$col]['label']))
						// Square with no number in it
						$class = 'not_a_day';
					elseif(!empty($GLOBALS['OUTPUT']->caldata[$row*7+$col]['events']))
						// Square with an event in it
						$class = 'event_day';
					else
						// Regular square with number
						$class = 'empty_day';
						
					$boldness = $GLOBALS['OUTPUT']->caldata[$row*7+$col]['today'] ? 'font-weight: bold;' : '';
					
					$rowdata .= <<<EOV
						<td onclick="document.getElementById('curevent').innerHTML = '{$GLOBALS['OUTPUT']->caldata[$row*7+$col]['events']}';" class='$class' $boldness">&nbsp;{$GLOBALS['OUTPUT']->caldata[$row*7+$col]['label']} </td>\n
EOV;
				
				}
				
				$rowdata .= "</tr>\n";
				
				if(empty($GLOBALS['OUTPUT']->caldata[$row*7+$col]['label'])) break;
			}
			
			$lastmonth = $GLOBALS['OUTPUT']->month-1;
			$nextmonth = $GLOBALS['OUTPUT']->month+1;
			
			return tpl_globals::calendar_styles() .			
<<<EOV
<table border='0' cellspacing='1' cellpadding='10' align='center' class='calendar_container'>
	<tr>
		<td class='month_nav' onclick="document.location='./index.php?act=calendar&month=$lastmonth&year={$GLOBALS['OUTPUT']->year}&format={$GLOBALS['OUTPUT']->format}'">&lt;&lt;</td>
		<td class='month_name' colspan='5'>{$GLOBALS['OUTPUT']->month_name} {$GLOBALS['OUTPUT']->year}</td>
		<td class='month_nav' onclick="document.location='./index.php?act=calendar&month=$nextmonth&year={$GLOBALS['OUTPUT']->year}&format={$GLOBALS['OUTPUT']->format}'">&gt;&gt;</td>
	</tr>
	<tr>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_1}</td>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_2}</td>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_3}</td>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_4}</td>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_5}</td>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_6}</td>
		<td class='day_name'>{$GLOBALS['LANG']->lang_intro->day_7}</td>
	</tr>
	{$rowdata}
</table>
EOV;
		}
		
	}

?>